// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.
#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]

/// Implements a client for the Security Command Center API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_securitycenter_v2::client::SecurityCenter;
/// let client = SecurityCenter::builder().build().await?;
/// // use `client` to make requests to the Security Command Center API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// V2 APIs for Security Center service.
///
/// # Configuration
///
/// To configure `SecurityCenter` use the `with_*` methods in the type returned
/// by [builder()][SecurityCenter::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://securitycenter.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::security_center::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::security_center::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `SecurityCenter` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `SecurityCenter` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct SecurityCenter {
    inner: std::sync::Arc<dyn super::stub::dynamic::SecurityCenter>,
}

impl SecurityCenter {
    /// Returns a builder for [SecurityCenter].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
    /// let client = SecurityCenter::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::security_center::ClientBuilder {
        gax::client_builder::internal::new_builder(super::builder::security_center::client::Factory)
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::SecurityCenter + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::SecurityCenter>> {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::SecurityCenter> {
        super::transport::SecurityCenter::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::SecurityCenter> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::SecurityCenter::new)
    }

    /// Creates a ResourceValueConfig for an organization. Maps user's tags to
    /// difference resource values for use by the attack path simulation.
    pub fn batch_create_resource_value_configs(
        &self,
    ) -> super::builder::security_center::BatchCreateResourceValueConfigs {
        super::builder::security_center::BatchCreateResourceValueConfigs::new(self.inner.clone())
    }

    /// Kicks off an LRO to bulk mute findings for a parent based on a filter. If
    /// no location is specified, findings are muted in global. The parent
    /// can be either an organization, folder, or project. The findings matched by
    /// the filter will be muted after the LRO is done.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn bulk_mute_findings(&self) -> super::builder::security_center::BulkMuteFindings {
        super::builder::security_center::BulkMuteFindings::new(self.inner.clone())
    }

    /// Creates a BigQuery export.
    pub fn create_big_query_export(&self) -> super::builder::security_center::CreateBigQueryExport {
        super::builder::security_center::CreateBigQueryExport::new(self.inner.clone())
    }

    /// Creates a finding in a location. The corresponding source must exist for
    /// finding creation to succeed.
    pub fn create_finding(&self) -> super::builder::security_center::CreateFinding {
        super::builder::security_center::CreateFinding::new(self.inner.clone())
    }

    /// Creates a mute config.
    pub fn create_mute_config(&self) -> super::builder::security_center::CreateMuteConfig {
        super::builder::security_center::CreateMuteConfig::new(self.inner.clone())
    }

    /// Creates a notification config.
    pub fn create_notification_config(
        &self,
    ) -> super::builder::security_center::CreateNotificationConfig {
        super::builder::security_center::CreateNotificationConfig::new(self.inner.clone())
    }

    /// Creates a source.
    pub fn create_source(&self) -> super::builder::security_center::CreateSource {
        super::builder::security_center::CreateSource::new(self.inner.clone())
    }

    /// Deletes an existing BigQuery export.
    pub fn delete_big_query_export(&self) -> super::builder::security_center::DeleteBigQueryExport {
        super::builder::security_center::DeleteBigQueryExport::new(self.inner.clone())
    }

    /// Deletes an existing mute config. If no location is specified, default is
    /// global.
    pub fn delete_mute_config(&self) -> super::builder::security_center::DeleteMuteConfig {
        super::builder::security_center::DeleteMuteConfig::new(self.inner.clone())
    }

    /// Deletes a notification config.
    pub fn delete_notification_config(
        &self,
    ) -> super::builder::security_center::DeleteNotificationConfig {
        super::builder::security_center::DeleteNotificationConfig::new(self.inner.clone())
    }

    /// Deletes a ResourceValueConfig.
    pub fn delete_resource_value_config(
        &self,
    ) -> super::builder::security_center::DeleteResourceValueConfig {
        super::builder::security_center::DeleteResourceValueConfig::new(self.inner.clone())
    }

    /// Gets a BigQuery export.
    pub fn get_big_query_export(&self) -> super::builder::security_center::GetBigQueryExport {
        super::builder::security_center::GetBigQueryExport::new(self.inner.clone())
    }

    /// Get the simulation by name or the latest simulation for the given
    /// organization.
    pub fn get_simulation(&self) -> super::builder::security_center::GetSimulation {
        super::builder::security_center::GetSimulation::new(self.inner.clone())
    }

    /// Get the valued resource by name
    pub fn get_valued_resource(&self) -> super::builder::security_center::GetValuedResource {
        super::builder::security_center::GetValuedResource::new(self.inner.clone())
    }

    /// Gets the access control policy on the specified Source.
    pub fn get_iam_policy(&self) -> super::builder::security_center::GetIamPolicy {
        super::builder::security_center::GetIamPolicy::new(self.inner.clone())
    }

    /// Gets a mute config. If no location is specified, default is
    /// global.
    pub fn get_mute_config(&self) -> super::builder::security_center::GetMuteConfig {
        super::builder::security_center::GetMuteConfig::new(self.inner.clone())
    }

    /// Gets a notification config.
    pub fn get_notification_config(
        &self,
    ) -> super::builder::security_center::GetNotificationConfig {
        super::builder::security_center::GetNotificationConfig::new(self.inner.clone())
    }

    /// Gets a ResourceValueConfig.
    pub fn get_resource_value_config(
        &self,
    ) -> super::builder::security_center::GetResourceValueConfig {
        super::builder::security_center::GetResourceValueConfig::new(self.inner.clone())
    }

    /// Gets a source.
    pub fn get_source(&self) -> super::builder::security_center::GetSource {
        super::builder::security_center::GetSource::new(self.inner.clone())
    }

    /// Filters an organization or source's findings and groups them by their
    /// specified properties in a location. If no location is specified, findings
    /// are assumed to be in global
    ///
    /// To group across all sources provide a `-` as the source id.
    /// The following list shows some examples:
    ///
    /// + `/v2/organizations/{organization_id}/sources/-/findings`
    ///
    /// `/v2/organizations/{organization_id}/sources/-/locations/{location_id}/findings`
    ///
    /// + `/v2/folders/{folder_id}/sources/-/findings`
    /// + `/v2/folders/{folder_id}/sources/-/locations/{location_id}/findings`
    /// + `/v2/projects/{project_id}/sources/-/findings`
    /// + `/v2/projects/{project_id}/sources/-/locations/{location_id}/findings`
    pub fn group_findings(&self) -> super::builder::security_center::GroupFindings {
        super::builder::security_center::GroupFindings::new(self.inner.clone())
    }

    /// Lists the attack paths for a set of simulation results or valued resources
    /// and filter.
    pub fn list_attack_paths(&self) -> super::builder::security_center::ListAttackPaths {
        super::builder::security_center::ListAttackPaths::new(self.inner.clone())
    }

    /// Lists BigQuery exports. Note that when requesting BigQuery exports at a
    /// given level all exports under that level are also returned e.g. if
    /// requesting BigQuery exports under a folder, then all BigQuery exports
    /// immediately under the folder plus the ones created under the projects
    /// within the folder are returned.
    pub fn list_big_query_exports(&self) -> super::builder::security_center::ListBigQueryExports {
        super::builder::security_center::ListBigQueryExports::new(self.inner.clone())
    }

    /// Lists an organization or source's findings.
    ///
    /// To list across all sources for a given location provide a `-` as the source
    /// id. If no location is specified, finding are assumed to be in global.
    /// The following list shows some examples:
    ///
    /// + `/v2/organizations/{organization_id}/sources/-/findings`
    ///
    /// `/v2/organizations/{organization_id}/sources/-/locations/{location_id}/findings`
    pub fn list_findings(&self) -> super::builder::security_center::ListFindings {
        super::builder::security_center::ListFindings::new(self.inner.clone())
    }

    /// Lists mute configs. If no location is specified, default is
    /// global.
    pub fn list_mute_configs(&self) -> super::builder::security_center::ListMuteConfigs {
        super::builder::security_center::ListMuteConfigs::new(self.inner.clone())
    }

    /// Lists notification configs.
    pub fn list_notification_configs(
        &self,
    ) -> super::builder::security_center::ListNotificationConfigs {
        super::builder::security_center::ListNotificationConfigs::new(self.inner.clone())
    }

    /// Lists all ResourceValueConfigs.
    pub fn list_resource_value_configs(
        &self,
    ) -> super::builder::security_center::ListResourceValueConfigs {
        super::builder::security_center::ListResourceValueConfigs::new(self.inner.clone())
    }

    /// Lists all sources belonging to an organization.
    pub fn list_sources(&self) -> super::builder::security_center::ListSources {
        super::builder::security_center::ListSources::new(self.inner.clone())
    }

    /// Lists the valued resources for a set of simulation results and filter.
    pub fn list_valued_resources(&self) -> super::builder::security_center::ListValuedResources {
        super::builder::security_center::ListValuedResources::new(self.inner.clone())
    }

    /// Updates the state of a finding. If no location is specified, finding is
    /// assumed to be in global
    pub fn set_finding_state(&self) -> super::builder::security_center::SetFindingState {
        super::builder::security_center::SetFindingState::new(self.inner.clone())
    }

    /// Sets the access control policy on the specified Source.
    pub fn set_iam_policy(&self) -> super::builder::security_center::SetIamPolicy {
        super::builder::security_center::SetIamPolicy::new(self.inner.clone())
    }

    /// Updates the mute state of a finding. If no location is specified, finding
    /// is assumed to be in global
    pub fn set_mute(&self) -> super::builder::security_center::SetMute {
        super::builder::security_center::SetMute::new(self.inner.clone())
    }

    /// Returns the permissions that a caller has on the specified source.
    pub fn test_iam_permissions(&self) -> super::builder::security_center::TestIamPermissions {
        super::builder::security_center::TestIamPermissions::new(self.inner.clone())
    }

    /// Updates a BigQuery export.
    pub fn update_big_query_export(&self) -> super::builder::security_center::UpdateBigQueryExport {
        super::builder::security_center::UpdateBigQueryExport::new(self.inner.clone())
    }

    /// Updates external system. This is for a given finding. If no location is
    /// specified, finding is assumed to be in global
    pub fn update_external_system(&self) -> super::builder::security_center::UpdateExternalSystem {
        super::builder::security_center::UpdateExternalSystem::new(self.inner.clone())
    }

    /// Creates or updates a finding. If no location is specified, finding is
    /// assumed to be in global. The corresponding source must exist for a finding
    /// creation to succeed.
    pub fn update_finding(&self) -> super::builder::security_center::UpdateFinding {
        super::builder::security_center::UpdateFinding::new(self.inner.clone())
    }

    /// Updates a mute config. If no location is specified, default is
    /// global.
    pub fn update_mute_config(&self) -> super::builder::security_center::UpdateMuteConfig {
        super::builder::security_center::UpdateMuteConfig::new(self.inner.clone())
    }

    /// Updates a notification config. The following update
    /// fields are allowed: description, pubsub_topic, streaming_config.filter
    pub fn update_notification_config(
        &self,
    ) -> super::builder::security_center::UpdateNotificationConfig {
        super::builder::security_center::UpdateNotificationConfig::new(self.inner.clone())
    }

    /// Updates an existing ResourceValueConfigs with new rules.
    pub fn update_resource_value_config(
        &self,
    ) -> super::builder::security_center::UpdateResourceValueConfig {
        super::builder::security_center::UpdateResourceValueConfig::new(self.inner.clone())
    }

    /// Updates security marks. For Finding Security marks, if no location is
    /// specified, finding is assumed to be in global. Assets Security Marks can
    /// only be accessed through global endpoint.
    pub fn update_security_marks(&self) -> super::builder::security_center::UpdateSecurityMarks {
        super::builder::security_center::UpdateSecurityMarks::new(self.inner.clone())
    }

    /// Updates a source.
    pub fn update_source(&self) -> super::builder::security_center::UpdateSource {
        super::builder::security_center::UpdateSource::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::security_center::ListOperations {
        super::builder::security_center::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::security_center::GetOperation {
        super::builder::security_center::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn delete_operation(&self) -> super::builder::security_center::DeleteOperation {
        super::builder::security_center::DeleteOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn cancel_operation(&self) -> super::builder::security_center::CancelOperation {
        super::builder::security_center::CancelOperation::new(self.inner.clone())
    }
}
